import math
a1=int(input())
b1=int(input())
op=int(input())
a2=int(input())
b2=int(input())
ans1=0;ans2=1;gcd=0
if(op==1):
    ans1=a1*b2+a2*b1
    ans2=b1*b2
elif(op==2):
    ans1=a1*b2-a2 * b1
    ans2=b1 *b2
elif(op==3):
    ans1=a1*a2
    ans2 =b1*b2
elif(op==4):
    ans1=a1 *b2
    ans2 =b1*a2
while(ans1!=1 and ans2!=1 and gcd!=1):
    d1 = ans1;
    d2=ans2;
    while(d1!=d2):
        d1=abs(d1-d2);
        d2=abs(d1-d2);
    gcd=d1
    ans1/=gcd;
    ans2/=gcd;
print(int(ans1))
print(int(ans2))